<template>
  <div class="invite-point-card">
    <div class="header">
      <span class="title">{{ property.title }}</span>
      <el-image v-if="property.titleIcon" :src="property.titleIcon" class="title-icon" />
    </div>
    <div class="content">
      <div class="block" @click="goPointLink" :class="{ clickable: !!property.pointLink }">
        <div class="value">{{ property.pointValue ?? 0 }}</div>
        <div class="desc">
          <el-image v-if="property.pointIcon" :src="property.pointIcon" class="icon" />
          <span>{{ property.pointLabel }}</span>
        </div>
      </div>
      <div class="block" @click="goInviteLink" :class="{ clickable: !!property.inviteLink }">
        <div class="value invite">{{ property.inviteValue ?? 0 }}<span class="unit">人</span></div>
        <div class="desc">
          <el-image v-if="property.inviteIcon" :src="property.inviteIcon" class="icon" />
          <span>{{ property.inviteLabel }}</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
const props = defineProps<{ property: any }>()
const goPointLink = () => {
  if (props.property.pointLink) {
    window.open(props.property.pointLink, '_blank')
  }
}
const goInviteLink = () => {
  if (props.property.inviteLink) {
    window.open(props.property.inviteLink, '_blank')
  }
}
</script>
<style scoped lang="scss">
.invite-point-card {
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px 0 rgb(0 0 0 / 3%);

  .header {
    display: flex;
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #374e60;
    align-items: center;

    .title {
      margin-right: 6px;
    }

    .title-icon {
      width: 18px;
      height: 18px;
    }
  }

  .content {
    display: flex;
    justify-content: space-between;

    .block {
      display: flex;
      flex-direction: column;
      align-items: center;
      flex: 1;
      cursor: pointer;

      &.clickable:hover {
        background: #f5f7fa;
        border-radius: 8px;
      }

      .value {
        margin-bottom: 2px;
        font-size: 28px;
        font-weight: 700;
        color: #1976d2;

        &.invite {
          color: #1976d2;
        }

        .unit {
          margin-left: 2px;
          font-size: 16px;
          font-weight: 400;
        }
      }

      .desc {
        display: flex;
        font-size: 13px;
        color: #888;
        align-items: center;

        .icon {
          width: 18px;
          height: 18px;
          margin-right: 4px;
        }
      }
    }
  }
}
</style>
